To help developers choose the best data handler for a specific situation while still making it easy for an application to find a usable data handler, Apple has defined two separate and complementary mechanisms for selecting data handler components. You can use the Component Manager's selection mechanisms to find a data handler that meets your needs and you can interrogate a data handler to determine if it supports a specific data reference. Both mechanisms rely on characteristics of the current data reference in order to make the selection.
Before you can use a data handler component, your application must open a connection to that component. The easiest way to open a connection to a data handler component is to call the Movie Toolbox's GetDataHandler function. You supply a data reference and the Movie Toolbox selects an appropriate data handler component for you. This function is preferred for opening a data handler as it reliably chooses the best data handler. For more information about this function, see the chapter "Movie Toolbox" in Inside Macintosh: QuickTime.
Alternatively, you may use the Component Manager to open your connection. Call the Component Manager's OpenDefaultComponent or OpenComponent function to do so, but be aware that these functions are often unable to make the best choice when there are several different data handlers available for a file.
At the most basic level, your application can use the Component Manager's built-in selection mechanisms to find a data handler component for a data reference. You may use the Component Manager's FindNextComponent function in order to retrieve a list of all data handler components that meet your needs. You specify your request by supplying the component's characteristics in a component description record--in particular, in the componentType , componentSubtype , componentManufacturer , and componentFlags fields.
All data handler components have a component type value of 'dhlr' , which is defined by the dataHandlerType constant. Data handler components use the value of the component subtype field to indicate the type of data reference they support. As a result of this convention, note that all data handlers that share a component subtype value must be able to recognize and work with data references of the same type. For example, file system data handlers always carry a component subtype value of 'alis' , which indicates that their data references are file system aliases (note that this is true for QuickTime on the Macintosh and under Windows, even though there is not, properly, a file system alias under Windows). Apple's memory-based data handler for the Macintosh has a component subtype value of 'hndl' .
Apple has not defined any special manufacturer field values or component flags values for data handler components. You may use the manufacturer field to select data handlers supplied by a specific vendor. To do so, you need to determine the appropriate manufacturer field value for that vendor.
While you can use the Component Manager's selection mechanisms to find a data handler component that can recognize data references of a specific type, your application must interact with the data handler in order to determine whether it can support a specific data reference. Apple has defined two functions, DataHCanUseDataRef and DataHGetVolumeList , that allow you to query a data handler component in order to find out whether it can work with a data reference. By using these two functions, your application can choose a data handler that is best-suited to its specific needs.
Using the DataHCanUseDataRef function, you supply a data reference to the data handler component. The component then reports what it can do with that data reference. The returned value indicates the level and, to some extent, the quality of service the data handler can provide (for example, whether the component can read data from or write data to the data reference and whether the component uses any special support when working with that data reference).
Because calling the DataHCanUseDataRef function in several data handlers can get time consuming, Apple has also defined a function that helps narrow the search. By using the DataHGetVolumeList function, your application can obtain a list of all the file system volumes that a data handler can support. In response to your request, the data handler returns the list and flags indicating the level and quality of service the data handler can provide for containers on that volume.
For more information on these functions, see "Selecting a Data Handler" .